package org.seckill.enums;

/**
 * Created by Administrator on 2017-8-13.
 */

public enum SeckillStateEnum {
    SUCCESS(1,"秒杀成功"),
    END(0,"秒杀结束"),
    REPEAT_KILL(-1,"重复秒杀"),
    DATE_REWRITE(-2,"数据篡改"),
    INNER_ERROR(-3,"系统异常")
    ;

    SeckillStateEnum() {
    }

    SeckillStateEnum(int state, String stateInfo) {
        this.state = state;
        this.stateInfo = stateInfo;
    }

    private int state;

    private String stateInfo;

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public String getStateInfo() {
        return stateInfo;
    }

    public void setStateInfo(String stateInfo) {
        this.stateInfo = stateInfo;
    }

    private static SeckillStateEnum stateOf(int index) {
        for(SeckillStateEnum stateEnum : values()) {
            if(stateEnum.getState() == index) return stateEnum;
        }
        return null;
    }

}
